Dynamic switching of multithreaded processor between single threaded and simultaneous multithreaded modes

ABSTRACT

An apparatus and program product utilize a multithreaded processor having at least one hardware thread among a plurality of hardware threads that is capable of being selectively activated and deactivated responsive to a control circuit. The control circuit additionally provides the capability of controlling how an inactive thread can be activated after the thread has been deactivated, e.g., by enabling or disabling reactivation in response to an interrupt.

CROSS-REFERENCE TO RELATED APPLICATIONS

This application is a continuation of U.S. patent application Ser. No.10/422,682, filed on Apr. 24, 2003 by William Joseph Armstrong et al.(ROC920030068US1), the entire disclosure of which is incorporated byreference herein.

FIELD OF THE INVENTION

The invention relates to computers and computer software, and inparticular, to multithreaded processors and switching of same betweensingle threaded and simultaneous multithreaded modes of operation.

BACKGROUND OF THE INVENTION

Given the continually increased reliance on computers in contemporarysociety, computer technology has had to advance on many fronts to keepup with increased demand. One particular subject of significant researchand development efforts is parallelism, i.e., the performance ofmultiple tasks in parallel.

A number of computer software and hardware technologies have beendeveloped to facilitate increased parallel processing. From a softwarestandpoint, multithreaded operating systems and kernels have beendeveloped, which permit computer programs to concurrently execute inmultiple “threads” so that multiple tasks can essentially be performedat the same time. Threads generally represent independent paths ofexecution for a program. For example, for an e-commerce computerapplication, different threads might be assigned to different customersso that each customer's specific e-commerce transaction is handled in aseparate thread.

From a software standpoint, some computers implement the concept oflogical partitioning, where a single physical computer is permitted tooperate essentially like multiple and independent “virtual” computers(referred to as logical partitions), with the various resources in thephysical computer (e.g., processors, memory, input/output devices)allocated among the various logical partitions. Each logical partitionexecutes a separate operating system, and from the perspective of usersand of the software applications executing on the logical partition,operates as a fully independent computer.

From a hardware standpoint, computers increasingly rely on multiplemicroprocessors to provide increased workload capacity. Furthermore,some microprocessors have been developed that support the ability toexecute multiple threads in parallel, effectively providing many of thesame performance gains attainable through the use of multiplemicroprocessors. One form of multithreaded processor, for example,supports the concurrent or simultaneous execution of multiple threads inhardware, a functionality often referred to as simultaneousmultithreading (SMT).

In an SMT processor, multiple hardware threads are defined in theprocessor, with each thread capable of executing a particular taskassigned to that thread. A suitable number of execution units, such asarithmetic logic units, fixed point units, load store units, floatingpoint units, etc., are configured to concurrently execute instructionsfrom multiple threads. Typically, most of the general purpose registers(GPR's) and special purpose registers (SPR's) that represent thearchitected state are replicated for each hardware thread in theprocessor. However, other on-chip resources, such as some SPR's, on-chipcaches, translation lookaside buffers, and other non-architectedresources are typically shared between multiple threads, with theexpectation being that when one or more hardware threads are stalled onlong latency events (e.g., waiting on cache misses), other threads cancontinue to progress and consume some of the chip resources.

For many workloads, SMT improves the overall performance (i.e., theoverall throughput) of a computer system. However, this improvementoften comes at the expense of the turnaround time for a single task, aseach task running on an SMT processor is required to share some of theon-chip resources with other tasks concurrently running on the sameprocessor. For example, cache access patterns of tasks running on otherhardware threads can adversely affect the performance of a particulartask, with the end result being a longer, and often unpredictableturnaround time for each individual task. It has been found, however,that in some applications, e.g., some scientific and engineeringapplications, the need for fast and predictable turnaround times ofindividual tasks may exceed the need for fast overall system throughput.In such instances, multithreading may actually hinder systemperformance.

Some multithreaded processor designs also support the ability to executein a single threaded mode, thus effectively disabling SMT and permittingtasks to run with a more predictable turnaround time. However, supportfor such functionality requires that switches between single-threadedand multithreaded modes occur via system restarts, or Initial ProgramLoads (IPL's). Given the availability requirements of many highperformance computer systems, however, system restarts are highlyundesirable, and often unacceptable to many customers.

In addition, even when it is desirable to operate a processor in an SMTmode, inefficiencies can still arise due to the consumption of sharedresources by the various hardware threads in the processor. For example,even when a hardware thread is executing an idle loop, and thusperforming no useful activities, shared resources are still beingconsumed by the hardware thread, thus taking resources away from otheractive threads that might otherwise be able to use such resources. As aresult, suboptimal performance can occur due to this consumption ofresources by threads that are not performing useful work on behalf ofthe system.

It would be highly desirable to facilitate the ability to providegreater control over the resources consumed by hardware threadsexecuting in a multithreaded processor, in particular, to reduce theinefficiencies that may occur due to the inefficient allocation ofresources among one or more of such threads in a multithreadedprocessor.

SUMMARY OF THE INVENTION

The invention addresses these and other problems associated with theprior art by providing an apparatus and program product that utilize amultithreaded processor having at least one hardware thread among aplurality of hardware threads that is capable of being selectivelyactivated and deactivated responsive to a control circuit. Furthermore,the control circuit additionally provides the capability of controllinghow an inactive thread can be activated after the thread has beendeactivated, typically through the specification of a reactivationcondition for the thread.

Through the provision of a control circuit that can control both whethera hardware thread is active or inactive, and how an inactive thread canbe activated, a number of useful performance enhancements may berealized. For example, some embodiments consistent with the inventionsupport the ability to control how an inactive thread can be activatedby controlling whether a thread can be reactivated in response to aninterrupt. Enabling an inactive thread to be activated in response to aninterrupt may permit, for example, a thread to be effectively taken“offline” with little system overhead, permitting any processorresources consumed by that thread to be utilized by other threads, butstill permitting the deactivated thread to be quickly and efficientlyreactivated via an interrupt to resume operations. As such, it may bepossible, for example, to enable the shared resources consumed by athread executing in an idle loop to be released for use by otherthreads, yet still permit the thread to be reactivated (and the sharedresources reacquired) relatively quickly, and with little systemoverhead.

Conversely, disabling the ability for a thread to be activated inresponse to an interrupt may support the ability to release sharedresources for an extended period of time in favor of more efficientoperation of any threads that are still active in a multithreadedprocessor. Furthermore, given that protection is afforded againstreactivation via an interrupt, often threads may be activated ordeactivated without requiring a system restart. As such, even ininstances of prolonged deactivation of a hardware thread, systemavailability is rarely if ever compromised.

These and other advantages and features, which characterize theinvention, are set forth in the claims annexed hereto and forming afurther part hereof. However, for a better understanding of theinvention, and of the advantages and objectives attained through itsuse, reference should be made to the Drawings, and to the accompanyingdescriptive matter, in which there is described exemplary embodiments ofthe invention.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram of the principal hardware components in alogically-partitioned computer consistent with the invention.

FIG. 2 is a block diagram of shared and dedicated resources utilized inthe multithreaded processor referenced in FIG. 1.

FIG. 3 is a flowchart illustrating the program flow of a switch tosingle threaded mode routine executed by the logically-partitionedcomputer of FIG. 1, to switch a multithreaded processor to a singlethreaded mode.

FIG. 4 is a flowchart illustrating the program flow of a switch tosimultaneous multithreaded mode routine executed by thelogically-partitioned computer of FIG. 1, to switch a multithreadedprocessor to a simultaneous multithreaded mode in a manner consistentwith the invention.

FIG. 5 is a flowchart illustrating the program flow of a logicalprocessor idle loop routine executed by the logically-partitionedcomputer of FIG. 1.

FIG. 6 is a flowchart illustrating the program flow of a switch tosingle threaded mode routine executed by a non-logically partitionedcomputer to switch a multithreaded processor to a single threaded modein a manner consistent with the invention.

FIG. 7 is a flowchart illustrating the program flow of a switch tosimultaneous multithreaded mode routine executed by a non-logicallypartitioned computer to switch a multithreaded processor to asimultaneous multithreaded mode in a manner consistent with theinvention.

FIG. 8 is a flowchart illustrating the program flow of a logicalprocessor idle loop routine executed by a non-logically partitionedcomputer.

DETAILED DESCRIPTION

The embodiments discussed hereinafter support the dynamic activation anddeactivation of selected hardware threads in a multithreaded processor,as well as the selective control of how inactive hardware threads may beactivated once deactivated.

A multithreaded processor consistent with the invention is typically asimultaneous multithreaded processor, although other forms ofmultithreaded processors may be used in the alternative. Moreover,practically any number of hardware threads may be supported in amultithreaded processor consistent with the invention, and any number ofsuch hardware threads may be selectively activated in the mannerdiscussed herein. For example, in the illustrated embodiments, asimultaneous multithreaded (SMT) processor is disclosed as including twohardware threads, with one such thread being capable of beingselectively deactivated to switch the processor between SMT andsingle-threaded (ST) modes.

The selective control of how an inactive hardware thread may beactivated once deactivated is typically based upon a reactivationcondition that is specified for a particular thread or processor, andmay vary in a number of manners consistent with the invention. Forexample, in the illustrated embodiments, a reactivation condition may bebased upon the selective enablement of thread activation responsive tointerrupts such as inter-processor interrupts (IPI's), I/O interrupts,timer or decrementer interrupts, etc. However, it will be appreciatedthat other controls that limit the ability of a thread to be activatedmay be used in the alternative.

Turning now to the Drawings, wherein like numbers denote like partsthroughout the several views, FIG. 1 illustrates the principal hardwarecomponents in a logically-partitioned computer 10 consistent with theinvention. Computer 10 generically represents, for example, any of anumber of multi-user computers such as a network server, a midrangecomputer, a mainframe computer, etc., e.g., an IBM eServer computer.However, it should be appreciated that the invention may be implementedin other computers and data processing systems, e.g., in single-usercomputers such as workstations, desktop computers, portable computers,and the like, or in other programmable electronic devices (e.g.,incorporating embedded controllers and the like). In addition, theinvention may also be utilized in connection with non-logicallypartitioned multithreaded computers.

Computer 10 generally includes one or more processors 12 coupled to amemory 14 via a bus 16. Each processor 12 may be implemented as a singlethreaded processor, or as a multithreaded processor, such as withprocessor 12 a, which is shown incorporating a plurality of hardwarethreads 18. For the most part, each hardware thread 18 in amultithreaded processor 12 a is treated like an independent processor bythe software resident in the computer. In this regard, for the purposesof this disclosure, a single threaded processor will be considered toincorporate a single hardware thread, i.e., a single independent unit ofexecution. It will be appreciated, however, that software-basedmultithreading or multitasking may be used in connection with bothsingle threaded and multithreaded processors to further support theparallel performance of multiple tasks in the computer.

In addition, as is also illustrated in FIG. 1, one or more of processors12 (e.g., processor 12 b) may be implemented as a service processor,which is used to run specialized firmware code to manage system initialprogram loads (IPL's), and to monitor, diagnose and configure systemhardware. Generally, computer 10 will include one service processor andmultiple system processors, which are used to execute the operatingsystems and applications resident in the computer, although theinvention is not limited to this particular implementation. In someimplementations, a service processor may be coupled to the various otherhardware components in the computer in manner other than through bus 16.

Memory 14 may include one or more levels of memory devices, e.g., aDRAM-based main storage, as well as one or more levels of data,instruction and/or combination caches, with certain caches eitherserving individual processors or multiple processors as is well known inthe art. Furthermore, memory 14 is coupled to a number of types ofexternal devices via a bus 20, e.g., one or more network adapters 22(for interfacing the computer with network(s) 24), one or more storagecontrollers 26 (for interfacing the computer with one or more storagedevices 28) and one or more workstation controllers 30 (for interfacingwith one or more terminals or workstations 32 via a plurality ofworkstation adapters).

FIG. 1 also illustrates in greater detail the primary softwarecomponents and resources utilized in implementing a logicallypartitioned computing environment on computer 10, including a pluralityof logical partitions 34 managed by a partition manager or hypervisor36. Any number of logical partitions may be supported as is well knownin the art, and the number of logical partitions resident at any time ina computer may change dynamically as partitions are added or removedfrom the computer.

In the illustrated IBM eServer-based implementation, partition manager36 is comprised of two layers of program code. The first, referred toherein as a non-dispatchable portion 38, is implemented within thefirmware, or licensed internal code (LIC), of computer 10, which isutilized to provide a low level interface to various hardware componentswhile isolating higher layers, e.g., the operating systems, from thedetails of the hardware access. The firmware may also communicate with aservice processor such as service processor 12 b. The non-dispatchableportion 38 provides many of the low level partition management functionsfor computer 10, e.g., page table management, etc. The non-dispatchableportion 38 also has no concept of tasks, and is accessible principallyvia function calls from higher layers of software.

The second layer of program code in partition manager 36 is referred toherein as a dispatchable portion 40. In contrast to non-dispatchableportion 38, which has no concept of tasks, is run with relocation off,and is accessible via function calls from higher layers of software, thedispatchable portion 40 has the concept of tasks (like any operatingsystem), and is run with relocation on. The dispatchable portiontypically executes in much the same manner as a partition, except thatit is hidden from the user. The dispatchable portion generally manageshigher level partition management operations such as creating anddeleting partitions, concurrent I/O maintenance, allocating processors,memory and other hardware resources to various partitions 34, etc.

Each logical partition 34 is typically statically and/or dynamicallyallocated a portion of the available resources in computer 10. Forexample, each logical partition may be allocated one or more processors12 and/or one or more hardware threads 18, as well as a portion of theavailable memory space. Logical partitions can share specific hardwareresources such as processors, such that a given processor is utilized bymore than one logical partition. In the alternative hardware resourcescan be allocated to only one logical partition at a time. Additionalresources, e.g., mass storage, backup storage, user input, networkconnections, and the I/O adapters therefor, are typically allocated toone or more logical partitions in a manner well known in the art.Resources may be allocated in a number of manners, e.g., on a bus-by-busbasis, or on a resource-by-resource basis, with multiple logicalpartitions sharing resources on the same bus. Some resources may even beallocated to multiple logical partitions at a time.

Each logical partition 34 utilizes an operating system 42 that controlsthe primary operations of the logical partition in the same manner asthe operating system of a non-partitioned computer. For example, eachoperating system 42 may be implemented using the OS/400 operating systemavailable from International Business Machines Corporation.

Each logical partition 34 executes in a separate, or independent, memoryspace, and thus each logical partition acts much the same as anindependent, non-partitioned computer from the perspective of each userapplication (user app) 44 that executes in each such logical partition.As such, user applications typically do not require any specialconfiguration for use in a partitioned environment.

Given the nature of logical partitions 34 as separate virtual computers,it may be desirable to support inter-partition communication to permitthe logical partitions to communicate with one another as if the logicalpartitions were on separate physical machines. As such, in someimplementations it may be desirable to support a virtual local areanetwork (LAN) 46 in non-dispatchable portion 38 to permit logicalpartitions 34 to communicate with one another via a networking protocolsuch as the Ethernet protocol. Other manners of supporting communicationbetween partitions may also be supported consistent with the invention.

It will be appreciated that other logically-partitioned environments maybe utilized consistent with the invention. For example, rather thanutilizing a dispatchable portion 40 that is separate from any partition34, the functionality of the dispatchable portion may be incorporatedinto one or more logical partitions in the alternative.

In general, the routines executed to implement the embodiments of theinvention, whether implemented as part of an operating system or aspecific application, component, program, object, module or sequence ofinstructions, or even a subset thereof, will be referred to herein as“computer program code,” or simply “program code.” Program codetypically comprises one or more instructions that are resident atvarious times in various memory and storage devices in a computer, andthat, when read and executed by one or more processors in a computer,cause that computer to perform the steps necessary to execute steps orelements embodying the various aspects of the invention. Moreover, whilethe invention has and hereinafter will be described in the context offully functioning computers and computer systems, those skilled in theart will appreciate that the various embodiments of the invention arecapable of being distributed as a program product in a variety of forms,and that the invention applies equally regardless of the particular typeof signal bearing media used to actually carry out the distribution.Examples of signal bearing media include but are not limited torecordable type media such as volatile and non-volatile memory devices,floppy and other removable disks, hard disk drives, magnetic tape,optical disks (e.g., CD-ROMs, DVDs, etc.), among others, andtransmission type media such as digital and analog communication links.

In addition, various program code described hereinafter may beidentified based upon the application or software component within whichit is implemented in a specific embodiment of the invention. However, itshould be appreciated that any particular program nomenclature thatfollows is used merely for convenience, and thus the invention shouldnot be limited to use solely in any specific application identifiedand/or implied by such nomenclature. Furthermore, given the typicallyendless number of manners in which computer programs may be organizedinto routines, procedures, methods, modules, objects, and the like, aswell as the various manners in which program functionality may beallocated among various software layers that are resident within atypical computer (e.g., operating systems, libraries, APIs,applications, applets, etc.), it should be appreciated that theinvention is not limited to the specific organization and allocation ofprogram functionality described herein.

Those skilled in the art will recognize that the exemplary environmentillustrated in FIG. 1 is not intended to limit the present invention.Indeed, those skilled in the art will recognize that other alternativehardware and/or software environments may be used without departing fromthe scope of the invention.

As noted above, the illustrated embodiments may be utilized to address anumber of problems that may arise in systems that utilize multithreadedprocessors. One such problem occurs as a result of slower andindeterminate turn around times for individual tasks when executed in amultithreading environment. It has been found that when reliable andfast turn around for a single task is desired, it may be desirable toswitch a mode for a multithreaded processor to disable one or morethreads, e.g., by operating the processor in a single-threaded (ST)mode. Moreover, it is often desirable that the mode switch occur withouthaving to reboot the system. It has also been found that it would alsobe desirable to similarly enable a switch from a single-threaded mode toa multithreaded (e.g., a simultaneous multithreading (SMT)) mode, alsowithout having to reboot the system.

Another problem that may be addressed is the consumption of sharedresources in a multithreaded processor by hardware threads that are notperforming productive work on behalf of the system. As will become moreapparent below, a hardware thread typically appears to an operatingsystem as an independent logical processor. As such, when a thread isoperating in an idle loop of an operating system, and is not doing anyuseful work, that thread is consuming certain shared resources of theprocessor and affecting the performance of other threads on theprocessor. It would therefore be desirable to enable an operating systemto switch a processor to single threaded mode when the thread is idle,and return the processor to SMT mode when work is available for thelogical processor, or when the logical processor is required to servicean interrupt. However, it has been found that putting a processor insingle threaded mode may appear to the operating system as if theprocessor is going off line. From an operating system perspective,taking a logical processor off line is typically an expensive operation.Moreover, the overhead of taking a logical processor off-line andreturning it to an on-line status when work is required may be such thatnothing is gained by disabling a thread when the thread enters an idleloop. It would be desirable to provide a mechanism to permit anoperating system to switch between single threaded and SMT mode withlittle overhead such that short-term periods where a thread is notperforming useful work may trigger a deactivation of a thread to free upshared resources for use by other threads.

Therefore, in the illustrated embodiment, it is desirable to provide anability to switch a multithreaded processor between single threaded andSMT modes without requiring a system restart or other limitation on theavailability of a computer. Furthermore, it is desirable to support thecapability to place a processor in single threaded mode to boostperformance of an active thread in such a way that the inactive threadappears to be on-line to the rest of an operating system.

To address these concerns, the illustrated embodiment supports aper-processor register, referred to herein as a “control” or “CTRL”register, that controls whether the processor is running in singlethreaded or SMT mode. In addition, another per-processor register isprovided to control how an inactive thread can be revived, e.g., via anexternal interrupt such as a timer or decrementer interrupt, aninterprocessor interrupt, an I/O interrupt, etc. The latter register isreferred to in the illustrated embodiment as a Hardware ImplementationDependent (HID) register, and it is this register that stores thereactivation condition specified for a particular thread. As will becomemore apparent below, when interrupts are disabled, typically a threadcan be revived only by an explicit action by another active thread inthe system.

Using the aforementioned mechanisms, if an operating system deems itdesirable to run a processor in single threaded mode for an extendedperiod of time, the operating system may select one or more threads onthat processor to make inactive. The operating system may then take thelogical processors corresponding to the target threads off-line. As partof taking a logical processor off-line, the operating system may ensurethat the thread will not be interrupted by an external interrupt sourcethrough appropriate control of the HID register, e.g., to specify areactivation condition whereby interrupts are disabled. The thread maythen go into a dead mode, whereby the thread is revivable only by anexplicit operation by an active thread on the processor. In such a mode,no state is maintained either in the hardware or in the software for adead thread. The thread then is able to make itself inactive by writingthe appropriate bits to the CTRL register.

To address the other problem noted above whenever a logical processorcorresponding to a thread goes into an idle loop, an operating systemmay make that thread inactive by writing to the CTRL register. Moreover,the operating system may program the HID register such that thereactivation condition specifies that the thread can be revived by anexternal interrupt, e.g., an I/O interrupt, an interprocessor interrupt,a timer interrupt, etc. The thread may then be placed in a “dormant”mode, where the state is maintained by the software, but the hardwaretakes away all resources from the dormant thread and allocates them toone or more active threads. Whenever an interrupt is triggered, thethread may then be revived and the corresponding logical processorreturned to its idle loop to determine whether it has any work to do asa result of the triggered interrupt. For example, if a decrementer ortimer expires or an I/O interrupt becomes pending, the thread may berevived to permit the corresponding logical processor to determinewhether any work is required as a result of the interrupt. Furthermore,if another processor wishes to make a task available for the logicalprocessor corresponding to the inactive thread, the other processor canrevive the inactive thread by sending an inter-processor interrupt tothe inactive thread, causing the logical processor to enter its idleloop to check for additional work. Also, if desired, the thread may beexplicitly revived by another thread in the system, as with a deadthread.

Now turning to FIG. 2, one specific implementation of the invention inlogically-partitioned computer 10 (FIG. 1) is illustrated. Specifically,FIG. 2 illustrates an exemplary multithreaded processor 50 including apair of hardware threads 52, designated as threads T0 and T1, which areconfigured to share a plurality of shared resources designated at 54.Each thread has a number of dedicated resources, e.g., a set of generalpurpose registers (GPR's) 56 and special purpose registers (SPR's) 58.In addition, each thread may share various of the shared resources 54,including, for example, on-chip cache memory 60, such as a data cacheand/or an instruction cache. Moreover, various SPR's 62, as well asstore queues 64, Effective to Real Address Translation (ERAT) tables 66,Translation Lookaside Buffers (TLB's) 68, etc., may be shared by threadsT0 and T1. Other types of resources may also be shared between thethreads in the manner described herein.

In addition, a control circuit 70, including a CTRL register 72 and anHID register 74, is also disposed in multithreaded processor 50, and isused to selectively activate and deactivate one or both of threads T0and T1. Each thread, in particular, is assigned at least one field ineach register 72, 74 to respectively specify (1) whether that thread isactive or inactive, and (2) whether or not that thread may bere-activated in response to an interrupt. It will be appreciated thatdifferent data structures may be utilized as an alternative to registers72, 74. For example, the various information in registers 72 and 74 maybe combined into a single register. In addition, it will be appreciatedthat different shared resources 54 may also be shared among threads T0and T1 consistent with the invention. Furthermore, it will beappreciated that any number of threads may be supported on the givenmultithreaded processor, and that all or only a portion of such threadsmay be selectively activated and deactivated in response to controlcircuit 70.

Control circuit 70 may also be configured to allocate shared resourcesbetween threads T0 and T1, as well as to save or discard certain stateinformation maintained in each hardware thread, or initiate the storageand retrieval of such state information as needed. Furthermore, controlcircuit 70 is configured to selectively activate or deactivate a threadwithout requiring a system restart. Further details regarding onesuitable implementation of a multithreaded processor having thecharacteristics described herein may be found in U.S. patent applicationSer. No. 10/422,648 (now U.S. Pat. No. 7,155,600, issued Dec. 26, 2006),entitled “METHOD AND LOGICAL APPARATUS FOR MANAGING THREAD EXECUTION INA SIMULTANEOUS MULTI-THREADED (SMT) PROCESSOR” (Attorney Docket No.AUS920030217US1), U.S. patent application Ser. No. 10/422,649 (expresslyabandoned Jun. 12, 2007, but published as U.S. Publication No.2004/0216101 on Oct. 28, 2004), entitled “METHOD AND LOGICAL APPARATUSFOR MANAGING RESOURCE REDISTRIBUTION IN A SIMULTANEOUS MULTI-THREADED(SMT) PROCESSOR” (Attorney Docket No. AUS920030267US1), and U.S. patentapplication Ser. No. 10/422,651, entitled “METHOD AND LOGICAL APPARATUSFOR RENAME REGISTER REALLOCATION IN A SIMULTANEOUS MULTI-THREADED (SMT)PROCESSOR” (now U.S. Pat. No. 7,290,261, issued Oct. 30, 2007) (AttorneyDocket No. AUS920030229US1), all of which filed on even date herewithand assigned to the same Assignee as the present invention, andincorporated by reference herein.

As noted above, computer 10 (FIG. 1) is configured as alogically-partitioned computer. In this computer, therefore, multipleoperating systems execute in multiple logical partitions. As such, thepartition manager in such a computer is configured to control whether apartition runs its processors in ST or SMT mode. It is desirable tomaintain such control in the partition manager to ensure partitioningintegrity of the computer. As such, the CTRL and HID registers describedabove are typically only writable by a partition manager whenever thecomputer is in a mode where it is capable of running multiplepartitions.

To support the herein-described functionality, the partition managerprovides services to each partition to allow such partitions to controlthe ST/SMT mode of each processor. Whenever a partition desires to takea logical processor off-line, a service, referred to herein as theH_STOP_SELF service, may be accessed on a thread that an operatingsystem wishes to make inactive. Moreover, to bring a logical processoron-line after being brought off-line, a partition may invoke anH_START_LOGICAL_PROCESSOR call to the partition manager to bring thelogical processor back on-line through revival of the dead thread.

When a partition wishes to make a thread dormant, e.g., in response to alogical processor entering an idle loop, the partition manager supportsan H_CEDE call, which the partition manager uses to make a threadinactive in a manner that the thread can be revived by one of any numberof types of interrupts. It is also desirable to permit a partition torevive a dormant thread also by invoking an H_PROD call. It will beappreciated that such calls may also be utilized for shared processorpartitions, as well as partitions that rely only on dedicate processors.

FIG. 3, for example, illustrates a switch to ST mode routine 100 thatmay be utilized to switch a multithreaded processor associated with aparticular partition to a single threaded mode. Routine 100 begins inblock 102 with a partition taking the logical processor associated witha thread going inactive off-line from the perspective of the operatingsystem. Next, in block 104, the thread going inactive calls thepartition manager to stop the thread, e.g., using the H_STOP_SELF calldescribed above. Next, in block 106, the thread going inactive, which isnow executing in the partition manager as a result of the aforementionedcall, sets the HID register to prevent revival of the thread via aninterrupt. Next, in block 108, the thread going inactive, and stillexecuting in the partition manager, sets the CTRL register to inactivatethe thread. By virtue of this operation, the control circuit in themultithreaded processor inactivates the thread, resulting in a processorswitch to single threaded mode.

To switch the aforementioned processor back to a SMT mode, routine 120of FIG. 4 may be performed. Routine 120 begins in block 122 by an activethread in the same partition calling the partition manager to start thepreviously inactive thread, e.g., using the aforementionedSTART_LOGICAL_PROCESSOR call. Next, as shown in block 124, the activethread, executing in the partition manager, writes the CTRL register torevive the inactive thread. By doing so, the control circuit on theprocessor will revive the inactive thread. Next, as shown in block 126,and as represented in FIG. 4 via a separate column, the previouslyinactive thread wakes up in the partition manager, and in particular, inreset handler program code resident in the partition manager. Next, inblock 128, the restored thread, now executing in the partition manager,gives control back to the partition that owns the thread, and as shownin block 130, the partition then brings the logical processor backon-line. Routine 120 is then complete.

Now turning to FIG. 5, a logical processor idle loop routine 140 may beexecuted whenever a logical processor executing in a partition enters anidle state. Routine 140 may thus briefly switch the multithreadedprocessor with which the logical processor is associated to a singlethreaded mode to free up any shared resources for consumption by otheractive threads in the processor.

Routine 140 begins in block 142 with the thread going inactive(currently executing in the partition) calling the partition manager tocede the thread. Next, in block 144, the thread going inactive, nowexecuting in the partition manager as a result of the call, saves thepartitioned state. Next, in block 146, the thread going inactive, againexecuting in the partition manager, sets the HID register to enablerevival of the thread via an interrupt. Then, in block 148, the threadgoing inactive, still executing in the partition manager, sets the CTRLregister to inactivate the thread. As a result of setting the register,the control circuit in the multithreaded processor then switches theprocessor to single threaded mode, thereby effectively inactivating thethread. The thread will then remain inactive until either explicitlyreactivated via a write to the CTRL register by another active thread(in a similar manner to that described above in connection with FIG. 4),or alternatively, in response to the reception of an interrupt.

For example, as shown in block 150, as a result of the reception of aninterrupt 152, the thread that has been inactivated as a result of aswitch to single threaded mode, wakes up at reset handler program codein the partition manager. Next, as shown in block 154, the thread, stillexecuting in the partition manager, then restores the partition stateand returns control to the partition. Next, as shown in block 156, theidle loop of the logical processor is then revived to process thereceived interrupt. Routine 140 is then complete, and processing by thelogical processor is resumed.

It will be appreciated that the principles of the invention may alsoapply to computers other than logically-partitioned computers. Forexample, FIGS. 6-8 illustrate corresponding routines to thoseillustrated in FIGS. 4-6, but instead utilized in anon-logically-partitioned computer. FIG. 6, for example, illustrates aswitch to ST mode routine 160 that may be executed by an operatingsystem to switch a multithreaded processor to ST mode. Routine 160begins in block 162 by taking the logical processor associated with athread going inactive to an off-line status. Next, in block 164, thethread going inactive sets the HID register to prevent revival of thethread via an interrupt. Next, in block 166, the thread going inactivesets the control register to inactivate the thread, whereby the controlcircuit on the processor inactivates the thread as described above.Routine 160 is then complete.

Next, as shown in FIG. 7, a switch to SMT mode routine 180 may revive aninactive thread in response to a write to the CTRL register by anotheractive thread executing in the computer (block 182). As a result of thewrite to the CTRL register, and as represented by a separate column inFIG. 7, the thread that was previously inactivated wakes up at resethandler program code in the operating system (block 184). Once woken up,the thread then brings the logical processor back on-line (block 186).Once the logical processor is then on-line, execution resumes in aconventional manner, and routine 180 is complete.

FIG. 8 illustrates a logical processor idle loop routine 200, whichbegins in block 202 with the thread going inactive, setting the HIDregister to enable revival of the thread via an interrupt. Then, asshown in block 204, the thread going inactive sets the CTRL register toinactivate the thread, thereby signaling to the control circuit on themultithreaded processor that the thread should be inactivated.

At some point in the future, the thread may be reactivated as shown atblock 206 in response to the reception of an interrupt 208. Once theinterrupt is received, the thread wakes up at reset handler program codein the operating system. Then, as shown in block 210, the idle loop isrevived to process the received interrupt. The logical processor thenresumes in a conventional manner, and routine 200 is complete.

As such, it may be seen that embodiments consistent with the inventionsupport the ability to selectively and dynamically activate anddeactivate hardware threads in a multithreaded processor, and oftenwithout requiring a system restart. Various modifications to theherein-described embodiments will be apparent to one of ordinary skillin the art having the benefit of the instant disclosure. Therefore, theinvention lies in the claims hereinafter appended.

1. A logically partitioned computer of the type including a plurality ofpartitions and a partition manager, the logically partitioned computercomprising: a multithreaded processor supporting the execution of aplurality of hardware threads, wherein a first hardware thread among theplurality of hardware threads is assigned to a logical processorresident in a first partition among the plurality of partitions; andprogram code configured upon execution to control the multithreadedprocessor by, in connection with taking the logical processor offline inthe first partition, deactivating the first hardware thread whileinhibiting reactivation of the first hardware thread in response toassertion of an interrupt, and in response to the logical processorentering an idle loop, deactivating the first hardware thread whilepermitting reactivation of the first hardware thread in response toassertion of an interrupt.
 2. An apparatus, comprising: a multithreadedprocessor supporting the execution of a plurality of hardware threads;and program code configured upon execution to specify a reactivecondition for a first hardware thread among the plurality of hardwarethreads executed by the multithreaded processor, the reactivationcondition determining how the first hardware thread may be activatedonce the first hardware thread has been deactivated, wherein thereactivation condition specifies whether the first hardware thread maybe activated in response to assertion of an interrupt such that thefirst hardware thread is prevented from being reactivated in response toassertion of an interrupt if so specified by the reactivation condition,wherein the program code is further configured to deactivate the firsthardware thread and selectively reactivate the first hardware threadbased upon the reactivation condition specified for the first hardwarethread; wherein the multithreaded processor includes a control circuitconfigured to selectively activate and deactivate the first hardwarethread, the control circuit further configured to reactivate the firsthardware thread based upon the reactivation condition, wherein thecontrol circuit comprises at least one register, and wherein the atleast one register includes first and second registers, the firstregister specifying whether the first hardware thread is active orinactive, and the second register specifying the reactivation condition.3. The apparatus of claim 2, wherein the interrupt includes at least oneof an external interrupt, inter-processor interrupt, input/outputinterrupt and timer interrupt.
 4. The apparatus of claim 2, wherein theprogram code is further configured to selectively prevent the firsthardware thread from being reactivated in response to assertion of aninterrupt generated while the first hardware thread is deactivated inresponse to the reactivation condition specifying that the firsthardware thread may not be activated in response to assertion of aninterrupt.
 5. The apparatus of claim 2, wherein the reactivationcondition specifies whether the first hardware thread may be activatedin response to assertion of any interrupt such that the first hardwarethread is prevented from being reactivated in response to assertion ofany interrupt if so specified by the reactivation condition.
 6. Anapparatus, comprising: a multithreaded processor supporting theexecution of a plurality of hardware threads; and program codeconfigured upon execution to specify a reactivation condition for afirst hardware thread among the plurality of hardware threads executedby the multithreaded processor, the reactivation condition determininghow the first hardware thread may be activated once the first hardwarethread has been deactivated, wherein the reactivation conditionspecifies whether the first hardware thread may be activated in responseto assertion of an interrupt such that the first hardware thread isprevented from being reactivated in response to assertion of aninterrupt if so specified by the reactivation condition, wherein theprogram code is further configured to deactivate the first hardwarethread and selectively reactivate the first hardware thread based uponthe reactivation condition specified for the first hardware thread;wherein the multithreaded processor is disposed in a computer comprisinga plurality of partitions and a partition manager that controls theplurality of partitions, wherein the partition manager code isconfigured to specify the reactivation condition and deactivate thefirst hardware thread, wherein the first hardware thread is associatedwith a logical processor executing in one of the plurality ofpartitions, and wherein the partition manager is configured to specify areactivation condition that inhibits reactivation of the first hardwarethread in response to assertion of an interrupt in connection with apartition taking the logical processor off-line.
 7. The apparatus ofclaim 6, wherein the program code is further configured to, inconnection with a partition bringing the logical processor back online,reactivate the first hardware thread using a second hardware threadexecuting program code for the partition manager.
 8. The apparatus ofclaim 6, wherein the first hardware thread is associated with a logicalprocessor executing in one of the plurality of partitions, the programcode further configured to detect with a partition that the logicalprocessor is executing in an idle loop, and in response thereto, specifya reactivation condition that permits reactivation of the first hardwarethread in response to assertion of an interrupt.
 9. The apparatus ofclaim 8, wherein the program code is configured to selectivelyreactivate the first hardware thread based upon the reactivationcondition specified for the first hardware thread by reactivating thefirst hardware thread in response to assertion of an interrupt, whereinthe logical processor is configured to process the received interrupt.10. The apparatus of claim 9, wherein the program code is furtherconfigured to save a state of a partition with which the logicalprocessor is associated in connection with the logical processorentering the idle loop, and restore the state of the partition withwhich the logical processor is associated in response to assertion ofthe interrupt.
 11. An apparatus, comprising: a multithreaded processorsupporting the execution of a plurality of hardware threads; and programcode configured upon execution to specify a reactivation condition for afirst hardware thread among the plurality of hardware threads executedby the multithreaded processor, the reactivation condition determininghow the first hardware thread may be activated once the first hardwarethread has been deactivated, wherein the reactivation conditionspecifies whether the first hardware thread may be activated in responseto assertion of an interrupt such that the first hardware thread isprevented from being reactivated in response to assertion of aninterrupt if so specified by the reactivation condition, wherein theprogram code is further configured to deactivate the first hardwarethread and selectively reactivate the first hardware thread based uponthe reactivation condition specified for the first hardware thread;wherein the multithreaded processor is disposed in a computer comprisingan operating system, wherein the first hardware thread is associatedwith a logical processor, wherein the operating system is configured tospecify the reactivation condition and deactivate the first hardwarethread, wherein the operating system is configured to specify areactivation condition that inhibits reactivation of the first hardwarethread in response to assertion of an interrupt in connection with thelogical processor being taken off-line, and wherein the operating systemis configured to specify a reactivation condition that permitsreactivation of the first hardware thread in response to assertion of aninterrupt in connection with the logical processor entering an idleloop.
 12. A program product, comprising: program code configured uponexecution to control a multithreaded processor in a logicallypartitioned computer of the type including a plurality of partitions anda partition manager, wherein the multithreaded processor supports theexecution of a plurality of hardware threads, wherein a first hardwarethread among the plurality of hardware threads is assigned to a logicalprocessor resident in a first partition among the plurality ofpartitions, and wherein the program code is configured to control themultithreaded processor by, in connection with taking the logicalprocessor offline in the first partition, deactivating the firsthardware thread while inhibiting reactivation of the first hardwarethread in response to assertion of an interrupt, and in response to thelogical processor entering an idle loop, deactivating the first hardwarethread while permitting reactivation of the first hardware thread inresponse to assertion of an interrupt; and a recordable computerreadable medium storing the program code.